package xyz.lisys.groovy

class MyPlugins {

    MyRunner alias(String name) {
        return new MyRunner(name)
    }

    class MyRunner {
        String name

        MyRunner(String name) {
            this.name = name
        }

        void apply(Boolean flag) {
            print "${this.name} ${flag ? '启用' : '禁用'}"
            println ""
        }
    }
}

class Args {
    String name
    MyPlugins.MyRunner from
}

static void gApply(HashMap args) {
    def a = (MyPlugins.MyRunner) args.from
    println a.name
}

static void myPlugins(Closure closure) {
    closure.delegate = new MyPlugins()
    closure()
}

myPlugins {
    alias('aa').apply(true)
    alias('bb') apply(false)
    alias('cc') apply true
}

def tasks = []

def task1 = { String it ->
    println it
}

static void execute(List<Closure> closures) {
    closures.forEach { it('a') }
}

execute tasks << { String it ->
    println it
}

def plugin = new MyPlugins()
gApply from: plugin.alias("NB")
